package ua.maxicash.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ua.maxicash.dao.WorkDao;
import ua.maxicash.vo.JobType;
import ua.maxicash.vo.Work;

import java.util.List;

@Service("workService")
public class WorkServiceImpl implements WorkService {

    @Autowired
    private WorkDao workDao;

//    @Autowired
//    private AlertService alertService;
    @Autowired
    private NotifyService notifyService;


    @Override
    public List<JobType> listJobTypes() {

        return workDao.listJobType();

    }

    @Override
    public JobType selectJobTypeById(Long id) {
        return workDao.selectJobType(id);
    }


    @Override
    public void addWork(Work work) {
        workDao.addWork(work);
        //alertService.sendNewWorkAlert(work);
        notifyService.notifyLikersAboutNewWork(work);
    }


    @Override
    public void updateWork(Work work) {
        workDao.updateWork(work);
        //alertService.sendEditedWorkAlert(work);
        notifyService.notifyLikersAndApplicantsAboutEditedWork(work);
    }

    @Override
    public Work getWorkById(Long id) {

        return workDao.getWorkById(id);

    }
}
